package com.central.scheduler.remote.command;

import com.central.common.properties.Property;
import com.central.scheduler.common.utils.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;
import java.util.List;

/**
 * @author Tindy
 * @date 2021/10/29
 * @describe
 */
public class TaskExecuteResponseCommand {
    public TaskExecuteResponseCommand() {
    }

    public TaskExecuteResponseCommand(Long taskInstanceId, Long processInstanceId) {
        this.taskInstanceId = taskInstanceId;
        this.processInstanceId = processInstanceId;
    }

    /**
     *  task instance id
     */
    private Long taskInstanceId;

    /**
     * process instance id
     */
    private  Long processInstanceId;

    /**
     *  status
     */
    private int status;


    /**
     *  end time
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;


    /**
     * processId
     */
    private int processId;

    /**
     * appIds
     */
    private String appIds;

    /**
     * varPool
     */
    private List<Property> varPool;

    public void setVarPool(List<Property> varPool) {
        this.varPool = varPool;
    }

    public List<Property> getVarPool() {
        return varPool;
    }

    public Long getTaskInstanceId() {
        return taskInstanceId;
    }

    public void setTaskInstanceId(Long taskInstanceId) {
        this.taskInstanceId = taskInstanceId;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public int getProcessId() {
        return processId;
    }

    public void setProcessId(int processId) {
        this.processId = processId;
    }

    public String getAppIds() {
        return appIds;
    }

    public void setAppIds(String appIds) {
        this.appIds = appIds;
    }

    /**
     * package response command
     * @return command
     */
    public Command convert2Command() {
        Command command = new Command();
        command.setType(CommandType.TASK_EXECUTE_RESPONSE);
        byte[] body = JSONUtils.toJsonByteArray(this);
        command.setBody(body);
        return command;
    }

    @Override
    public String toString() {
        return "TaskExecuteResponseCommand{"
                + "taskInstanceId=" + taskInstanceId
                + ", status=" + status
                + ", endTime=" + endTime
                + ", processId=" + processId
                + ", appIds='" + appIds + '\''
                + '}';
    }

    public Long getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(Long processInstanceId) {
        this.processInstanceId = processInstanceId;
    }
}
